package adv2;

public class Yuangong implements Comparable<Yuangong> {

	// ，员工有工号，姓名，年龄，性别，职务，薪水等属性
	private String name;
	private int age;
	private String sex;
	private String zhiwu;
	private double xinshui;
	private String gonghao;

	public Yuangong(String name, int age, String sex, String zhiwu, double xinshui, String gonghao) {
		super();
		this.name = name;
		this.age = age;
		this.sex = sex;
		this.zhiwu = zhiwu;
		this.xinshui = xinshui;
		this.gonghao = gonghao;
	}

	public Yuangong() {
		// TODO 自动生成的构造函数存根
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getZhiwu() {
		return zhiwu;
	}

	public void setZhiwu(String zhiwu) {
		this.zhiwu = zhiwu;
	}

	public double getXinshui() {
		return xinshui;
	}

	public void setXinshui(double xinshui) {
		this.xinshui = xinshui;
	}

	public String getGonghao() {
		return gonghao;
	}

	public void setGonghao(String gonghao) {
		this.gonghao = gonghao;
	}

	@Override
	public String toString() {
		// TODO 自动生成的方法存根
		return "姓名:" + name + ",年龄:" + age + ",性别:" + sex + ",职务:" + zhiwu + ",薪水:" + xinshui + ",工号:" + gonghao;
	}

	@Override
	public int hashCode() {

		final int prime = 31;
		int result = 1;
		result = prime * result + ((gonghao == null) ? 0 : gonghao.hashCode());
		// System.out.println("当前对象的hashCod=" + result);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		// System.out.println(">>>>>>>>>>>现在开始比较对象了>>>>>>>>>>>>>" + this + "<><><><>" +
		// obj);
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Yuangong other = (Yuangong) obj;
		if (gonghao == null) {
			if (other.gonghao != null)
				return false;
		} else if (!gonghao.equals(other.gonghao))
			return false;
		return true;
	}

	@Override
	public int compareTo(Yuangong o) {
		// this和o比较
		return this.age - o.age;
		// return (int) (this.xinshui - o.xinshui);
		// return this.gonghao.compareTo(o.gonghao);
	}

}